home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
dev
/
gui
/
muibuilderv11.lha
/
muibuilder
/
mb
/
e
/
click_locale
/
Click.e
< prev
next >
Wrap
Text File
|
1994-03-15
|
7KB
|
195 lines
/******************************************************************************
Here is an example of an "environnement file". All you have to do, si to
fill it with :
- some constant declarations and array initialisations for localisation
- use MUIBuilder+GenCodeE to generate the create_app() function
- add the code for your application !!!
******************************************************************************/
OPT OSVERSION=37
/* Module definitions */
MODULE 'muimaster', 'libraries/mui'
MODULE 'utility/tagitem', 'utility/hooks'
MODULE 'intuition/classes', 'intuition/classusr'
MODULE 'locale', 'libraries/locale'
/* Error handling */
ENUM NO_LIBRARY, MUI_APPLICATION_FAILURE
RAISE NO_LIBRARY IF OpenLibrary()=NIL,
MUI_APPLICATION_FAILURE IF Mui_NewObjectA()=NIL
/* Object definitions */
OBJECT fc_type
id :LONG
str :LONG
ENDOBJECT
/* Constant definitions */
CONST MUI_TRUE = 1
/******************************************
Add here some constant declarations
for localisation.
******************************************/
CONST MSG_AppDescription = 0
CONST MSG_WI_try = 1
CONST MSG_TX_label_0 = 2
CONST MSG_BT_1stbutton = 3
CONST MSG_BT_2ndbutton = 4
CONST MSG_BT_3rdbutton = 5
/* Global variables */
DEF catalog_Click:PTR TO catalog
DEF array_Click[6]:ARRAY OF fc_type /* Update array size */
/*MUIB*/ DEF app, wi_try, tx_label_0, bt_1stbutton, bt_2ndbutton, bt_3rdbutton
/*MUIB*/ DEF stR_TX_label_0 : PTR TO CHAR
/* Main procedure */
PROC main() HANDLE
DEF signal, result_DoMethod, running = TRUE
localebase := OpenLibrary('locale.library', 0)
muimasterbase := OpenLibrary('muimaster.library', 0)
open_Click_catalog(NIL, NIL)
create_app()
/* Notify : close gadget => end of application */
doMethod( wi_try, [ MUIM_Notify, MUIA_Window_CloseRequest, MUI_TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit ] )
/* Open the window */
set( wi_try, MUIA_Window_Open , MUI_TRUE )
WHILE running
result_DoMethod := doMethod( app, [ MUIM_Application_Input, {signal} ] )
SELECT result_DoMethod
CASE MUIV_Application_ReturnID_Quit
running := FALSE
ENDSELECT
IF (running AND signal) THEN Wait( signal )
ENDWHILE
Mui_DisposeObject( app )
close_Click_catalog()
CloseLibrary( muimasterbase )
CloseLibrary( localebase )
EXCEPT
SELECT exception
CASE NO_LIBRARY
CASE MUI_APPLICATION_FAILURE
ENDSELECT
ENDPROC
/* Procedure generated by GenCodeE which creates your application */
PROC create_app()
stR_TX_label_0 := get_Click_string( MSG_TX_label_0 )
app := ApplicationObject,
MUIA_Application_Author, 'Eric Totel',
MUIA_Application_Base, 'CLICK',
MUIA_Application_Title, 'Click',
MUIA_Application_Version, '$VER : Click 1.0',
MUIA_Application_Copyright, 'Eric Totel 1994',
MUIA_Application_Description, get_Click_string( MSG_AppDescription ),
SubWindow, wi_try := WindowObject,
MUIA_Window_Title, get_Click_string( MSG_WI_try ),
MUIA_Window_ID, MAKE_ID( "0", "W", "I", "N" ),
WindowContents, GroupObject,
Child, tx_label_0 := TextObject,
MUIA_Background, 131,
MUIA_Text_Contents, stR_TX_label_0,
MUIA_Text_SetMax, 0,
MUIA_Text_SetMin, 1,
MUIA_Frame, 9,
End,
Child, GroupObject,
MUIA_Group_Horiz, MUI_TRUE,
MUIA_Group_SameWidth, MUI_TRUE,
Child, bt_1stbutton := et_key_button( get_Click_string( MSG_BT_1stbutton ) ),
Child, bt_2ndbutton := et_key_button( get_Click_string( MSG_BT_2ndbutton ) ),
Child, bt_3rdbutton := et_key_button( get_Click_string( MSG_BT_3rdbutton ) ),
End,
End,
End,
End
ENDPROC
/* DoMethod() function */
PROC doMethod( obj:PTR TO object, msg:PTR TO msg )
DEF h:PTR TO hook, o:PTR TO object, dispatcher
IF obj
o := obj-SIZEOF object /* instance data is to negative offset */
h := o.class
dispatcher := h.entry /* get dispatcher from hook in iclass */
MOVEA.L h,A0
MOVEA.L msg,A1
MOVEA.L obj,A2 /* probably should use CallHookPkt, but the */
MOVEA.L dispatcher,A3 /* original code (DoMethodA()) doesn't. */
JSR (A3) /* call classDispatcher() */
MOVE.L D0,o
RETURN o
ENDIF
ENDPROC NIL
/* Extended KeyButton for localized buttons */
PROC et_key_button( text:PTR TO CHAR ) RETURN KeyButton( (text+3), text[1] )
/* An easy OpenCatalog() function */
PROC open_Click_catalog(loc:PTR TO locale, language:PTR TO CHAR)
DEF tag, tagarg, dummy_var = 0
/******************************************
Add here some array initialisations
for localisation.
******************************************/
array_Click[dummy_var].id := MSG_AppDescription; array_Click[dummy_var++].str := 'just a demo !!!'
array_Click[dummy_var].id := MSG_WI_try; array_Click[dummy_var++].str := 'Click !!!'
array_Click[dummy_var].id := MSG_TX_label_0; array_Click[dummy_var++].str := '\e8\ecClick on buttons'
array_Click[dummy_var].id := MSG_BT_1stbutton; array_Click[dummy_var++].str := '_1 Button 1'
array_Click[dummy_var].id := MSG_BT_2ndbutton; array_Click[dummy_var++].str := '_2 Button 2'
array_Click[dummy_var].id := MSG_BT_3rdbutton; array_Click[dummy_var++].str := '_3 Button 3'
IF (localebase AND (catalog_Click = NIL))
IF language
tag := OC_LANGUAGE
tagarg := language
ELSE
tag:= TAG_IGNORE
ENDIF
catalog_Click := OpenCatalogA(loc, 'Click.catalog',
[ OC_BUILTINLANGUAGE, 'english', /* Update built-in language */
tag, tagarg,
OC_VERSION, 0, /* Update catalog version number */
TAG_DONE ])
ENDIF
ENDPROC
/* An easy CloseCatalog() function */
PROC close_Click_catalog()
IF localebase THEN CloseCatalog( catalog_Click )
catalog_Click := NIL
ENDPROC
/* A GetString() function for localized strings */
PROC get_Click_string( strnum )
DEF defaultstr:PTR TO CHAR, i = 0
/* Fill the 2 (i < ?) tests by the array size */
WHILE ((i < 6) AND (array_Click[i].id <> strnum)) DO INC i
defaultstr := IF (i < 6) THEN array_Click[i].str ELSE NIL
ENDPROC IF catalog_Click THEN GetCatalogStr( catalog_Click, strnum, defaultstr ) ELSE defaultstr